package com.maiyuren.fishkit.utils

import android.app.AlertDialog
import android.widget.Toast
import androidx.annotation.DrawableRes
import com.maiyuren.fishkit.FishkitApplication
import com.maiyuren.fishkit.ui.route.MainActivity


object FishAlertUtils {
    fun alert(content: String, title : String = "提示") {

    }

    fun toast(content: String) {
        Toast.makeText(FishkitApplication.instance,
            content, Toast.LENGTH_SHORT).show()
    }

    fun confirm(
        title:String,
        confirmButtonText: String = "確認",
        @DrawableRes icon: Int = 0,
        onCancel: (()-> Unit)? = null,
        onConfirm: ()-> Unit
    ) {
        val builder = AlertDialog.Builder(MainActivity.instance)
        builder.setTitle(title)
        if (icon != 0) builder.setIcon(icon)
        builder.setPositiveButton(confirmButtonText){ arg0, arg1 ->
            onConfirm();
        }
        builder.setNegativeButton("取消") { arg0, arg1 ->
            if (onCancel != null) onCancel();
        }
        val b = builder.create()
        b.show()
    }
}